package com.fastjrun.security.utils;

import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;

@Slf4j
public class WhiteUrlUtils {
  public static String[] getProperties(String fileName) throws IOException {
    ClassPathResource resource = new ClassPathResource(fileName);
    BufferedReader bufferedReader =
        new BufferedReader(new InputStreamReader(resource.getInputStream()));
    String url;
    List<String> whiteUrls = Lists.newArrayList();
    int index=0;
    while ((url = bufferedReader.readLine()) != null) {
      whiteUrls.add(url);
      log.info("读取配置文件信息:url[{}]={}",index++, url);
    }
    return whiteUrls.toArray(new String[0]);
  }
}
